package me.shan.bit;

import org.junit.Assert;

/**
 * 描述：一个数组，只有一种数有奇数个，其他数都是偶数个，求奇数个的数值
 *
 * @author liuchuang
 * @date 2021/6/14
 */
public class OddAndEven {

    public static int function(int[] array) {
        int a = 0;
        for (int i : array) {
            a ^= i;
        }
        return a;
    }

    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 1, 5, 4, 3, 2, 1};
        Assert.assertEquals(1, function(array));
    }



}
